
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Atlas之启动过程(一) · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.2">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="atlas_start_2.html" />
    
    
    <link rel="prev" href="../atlas_gradle_apk/atlas_atlas_gradle_apk.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    原理解析
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../../principle-intro/Runtime_principle.html">
            
                <a href="../../principle-intro/Runtime_principle.html">
            
                    
                    框架原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../../principle-intro/Project_architectured.html">
            
                <a href="../../principle-intro/Project_architectured.html">
            
                    
                    名词解释
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../../principle-intro/Apk_architecture.html">
            
                <a href="../../principle-intro/Apk_architecture.html">
            
                    
                    APK结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../../principle-intro/File_architecture_runtime.html">
            
                <a href="../../principle-intro/File_architecture_runtime.html">
            
                    
                    运行期文件结构
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../../guide-for-use/">
            
                <a href="../../guide-for-use/">
            
                    
                    接入指引
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../../guide-for-use/guide_for_build.html">
            
                <a href="../../guide-for-use/guide_for_build.html">
            
                    
                    容器接入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../../guide-for-use/guide_for_bundle.html">
            
                <a href="../../guide-for-use/guide_for_bundle.html">
            
                    
                    bundle拆分|新建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../../guide-for-use/guide_for_compile.html">
            
                <a href="../../guide-for-use/guide_for_compile.html">
            
                    
                    awo编译
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../../guide-for-use/bundleCommunicate.html">
            
                <a href="../../guide-for-use/bundleCommunicate.html">
            
                    
                    跨bundle的代码重用和通信
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../../update/">
            
                <a href="../../update/">
            
                    
                    动态部署
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../../update/principle.html">
            
                <a href="../../update/principle.html">
            
                    
                    技术原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../../update/dexpatch.html">
            
                <a href="../../update/dexpatch.html">
            
                    
                    dexpatch
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../../update/dexpatch_use_guide.html">
            
                <a href="../../update/dexpatch_use_guide.html">
            
                    
                    dexpatch使用教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../../update/guide.html">
            
                <a href="../../update/guide.html">
            
                    
                    一些限制
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    FAQ
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../../faq/question.html">
            
                <a href="../../faq/question.html">
            
                    
                    问答
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../../faq/help.html">
            
                <a href="../../faq/help.html">
            
                    
                    故障排查
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../../faq/variant.html">
            
                <a href="../../faq/variant.html">
            
                    
                    构建定制包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../../faq/dynamic_failed_help.html">
            
                <a href="../../faq/dynamic_failed_help.html">
            
                    
                    动态部署失败排查指南
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    源码分析
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../atlas_gradle_apk/atlas_atlas_gradle_apk.html">
            
                <a href="../atlas_gradle_apk/atlas_atlas_gradle_apk.html">
            
                    
                    Atlas之Gradle配置
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.6.2" data-path="atlas_start_1.html">
            
                <a href="atlas_start_1.html">
            
                    
                    Atlas之启动过程(一)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="atlas_start_2.html">
            
                <a href="atlas_start_2.html">
            
                    
                    Atlas之启动过程(二)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../atlas_bundle_load/atlas_bundle_load.html">
            
                <a href="../atlas_bundle_load/atlas_bundle_load.html">
            
                    
                    Atlas之Bundle加载过程
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >Atlas之启动过程(一)</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x6982;&#x8FF0;">&#x6982;&#x8FF0;</h1>
<p>Atlas&#x6574;&#x4E2A;&#x542F;&#x52A8;&#x8FC7;&#x7A0B;&#x7684;&#x65F6;&#x5E8F;&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;&#xFF0C;&#x672C;&#x7BC7;&#x53EA;&#x5173;&#x6CE8;&#x4E0B;&#x56FE;&#x4E2D;&#x7684;1-5&#x6B65;&#x3002;</p>
<p><img src="atlas_core_start_img.svg" alt=""></p>
<h1 id="&#x5165;&#x53E3;">&#x5165;&#x53E3;</h1>
<p>&#x6211;&#x4EEC;&#x90FD;&#x77E5;&#x9053;&#xFF0C;app&#x7684;&#x5165;&#x53E3;&#x662F;application&#xFF0C;&#x90A3;&#x4E48;atlas&#x7684;&#x5165;&#x53E3;application&#x662F;&#x4EC0;&#x4E48;&#x5462;&#xFF0C;&#x770B;&#x4E00;&#x4E0B;app&#x6A21;&#x5757;&#x4E2D;manifest&#x4E2D;&#x7684;&#x5B9A;&#x4E49;</p>
<p><img src="atlas_application_demo.png" alt=""></p>
<p>&#x770B;&#x6837;&#x5B50;&#xFF0C;&#x662F;DemoApplication<br>
&#x771F;&#x7684;&#x662F;&#x8FD9;&#x6837;&#x7684;&#x5417;&#xFF1F;<br>
<strong>&#x5F53;&#x7136;&#x4E0D;&#x662F;</strong></p>
<p>&#x6211;&#x4EEC;&#x770B;&#x4E00;&#x4E0B;&#x53CD;&#x7F16;&#x8BD1;&#x540E;&#x7684;manifest</p>
<p><img src="atlas_manifest_application.png" alt=""></p>
<p>&#x4E3A;&#x4EC0;&#x4E48;&#x4F1A;&#x662F;AtlasBridgeApplication&#x5462;&#xFF0C;manifest&#x4E2D;&#x660E;&#x660E;&#x5199;&#x7684;&#x5F88;&#x6E05;&#x695A; : DemoApplication&#x3002;<br>
&#x4E8B;&#x5B9E;&#x4E0A;&#x4E3A;&#x4E86;&#x63A5;&#x5165;&#x7684;&#x65B9;&#x4FBF;&#xFF0C;Atlas&#x5728;&#x7F16;&#x8BD1;&#x671F;&#x5C31;&#x66FF;&#x6362;&#x4E86;&#x5165;&#x53E3;application&#x3002;&#x4E0D;&#x8FC7;&#xFF0C;Atlas&#x4FDD;&#x8BC1;&#x5728;&#x8FD0;&#x884C;&#x671F;&#x65F6;&#x4F1A;&#x8C03;&#x7528;DemoApplication&#x7684;&#x76F8;&#x5173;&#x65B9;&#x6CD5;&#x3002;</p>
<h1 id="1-atlasbridgeapplicationattachbasecontext">1. AtlasBridgeApplication.attachBaseContext</h1>
<p>&#x6211;&#x4EEC;&#x770B;&#x4E00;&#x4E0B;AtlasBridgeApplication&#x4E2D;&#x7684;&#x76F8;&#x5173;&#x65B9;&#x6CD5;</p>
<pre><code class="lang-java"><span class="hljs-meta">@Override</span>
<span class="hljs-function"><span class="hljs-keyword">protected</span> <span class="hljs-keyword">void</span> <span class="hljs-title">attachBaseContext</span><span class="hljs-params">(Context base)</span> </span>{
    <span class="hljs-keyword">super</span>.attachBaseContext(base);
    <span class="hljs-comment">//...&#x4E00;&#x4E9B;&#x903B;&#x8F91;</span>

    <span class="hljs-comment">//1. &#x6784;&#x9020;BridgeApplicationDelegate&#x5BF9;&#x8C61;</span>
    Class BridgeApplicationDelegateClazz = getBaseContext().getClassLoader().loadClass(<span class="hljs-string">&quot;android.taobao.atlas.bridge.BridgeApplicationDelegate&quot;</span>);
    Constructor&lt;?&gt; con = BridgeApplicationDelegateClazz.getConstructor(parTypes);
    mBridgeApplicationDelegate = con.newInstance(<span class="hljs-keyword">this</span>,getProcessName(...);

    <span class="hljs-comment">//2. &#x6267;&#x884C;BridgeApplicationDelegate&#x7684;attachBaseContext&#x65B9;&#x6CD5;</span>
    Method method = BridgeApplicationDelegateClazz.getDeclaredMethod(<span class="hljs-string">&quot;attachBaseContext&quot;</span>);
    method.invoke(mBridgeApplicationDelegate);
}
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x4EE3;&#x7801;&#x867D;&#x957F;&#xFF0C;&#x4F46;&#x5176;&#x5B9E;&#x5C31;&#x53EA;&#x5E72;&#x4E86;&#x4E24;&#x4EF6;&#x4E8B;&#x3002;</p>
<ul>
<li>&#x53CD;&#x5C04;&#x5E76;&#x6784;&#x9020;BridgeApplicationDelegate&#x7684;&#x5B9E;&#x4F8B;</li>
<li>&#x6267;&#x884C;BridgeApplicationDelegate&#x7684;attachBaseContext&#x65B9;&#x6CD5;&#x3002;</li>
</ul>
<p>&#x5148;&#x770B;BridgeApplicationDelegate&#x7684;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x3002;</p>
<pre><code class="lang-java"><span class="hljs-comment">//BridgeApplicationDelegate.java</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">BridgeApplicationDelegate</span><span class="hljs-params">(Application rawApplication...)</span></span>{
    mRawApplication = rawApplication;
    PackageManagerDelegate.delegatepackageManager(
        rawApplication.getBaseContext()
    );
}
</code></pre>
<p>&#x6CA1;&#x4EC0;&#x4E48;&#x5185;&#x5BB9;&#xFF0C;&#x76F4;&#x63A5;&#x8DDF;&#x8FDB;<code>delegatepackageManager</code>&#x7684;&#x51FD;&#x6570;&#x5B9E;&#x73B0;</p>
<pre><code class="lang-java"><span class="hljs-comment">//PackageManagerDelegate.java</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">delegatepackageManager</span><span class="hljs-params">(Context context)</span></span>{
      mBaseContext = context;
      <span class="hljs-comment">//1. &#x53CD;&#x5C04;pm</span>
      PackageManager manager = mBaseContext.getPackageManager();
      Class ApplicationPackageManager = Class.forName(<span class="hljs-string">&quot;android.app.ApplicationPackageManager&quot;</span>);
      Field field = ApplicationPackageManager.getDeclaredField(<span class="hljs-string">&quot;mPM&quot;</span>);
      field.setAccessible(<span class="hljs-keyword">true</span>);
      Object rawPm = field.get(manager);
      <span class="hljs-comment">//2. &#x52A8;&#x6001;&#x4EE3;&#x7406;pm</span>
      Class IPackageManagerClass = Class.forName(<span class="hljs-string">&quot;android.content.pm.IPackageManager&quot;</span>);
      mPackageManagerProxyhandler = <span class="hljs-keyword">new</span> PackageManagerProxyhandler(rawPm);            
      mProxyPm = Proxy.newProxyInstance(mBaseContext.getClassLoader(), <span class="hljs-keyword">new</span> Class[]{IPackageManagerClass}, mPackageManagerProxyhandler);
      <span class="hljs-comment">//3. &#x66FF;&#x6362;pm</span>
      field.set(manager, mProxyPm);
}
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#x7684;&#x6838;&#x5FC3;&#x601D;&#x60F3;&#x5C31;&#x662F;&#x5C06;&#x7CFB;&#x7EDF;&#x7684;pm&#xFF0C;&#x66FF;&#x6362;&#x4E3A;&#x6211;&#x4EEC;&#x5B9E;&#x73B0;&#x7684;PackageManagerProxyhandler&#x3002;&#x6211;&#x4EEC;&#x5148;&#x4E0D;&#x5173;&#x6CE8;PackageManagerProxyhandler&#x7684;&#x5B9E;&#x73B0;&#xFF0C;&#x63A5;&#x7740;&#x770B;<code>BridgeApplicationDelegate</code>&#x4E2D;&#x51FD;&#x6570;attachBaseContext&#x7684;&#x5B9E;&#x73B0;&#x3002;</p>
<h1 id="2-bridgeapplicationdelegate-attachbasecontext">2. BridgeApplicationDelegate. attachBaseContext</h1>
<p>BridgeApplicationDelegate.java</p>
<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">attachBaseContext</span><span class="hljs-params">()</span></span>{
    <span class="hljs-comment">//2.1 hook&#x4E4B;&#x524D;&#x51C6;&#x5907;&#x5DE5;&#x4F5C;</span>
    AtlasHacks.defineAndVerify();

    <span class="hljs-comment">//2.2 &#x56DE;&#x8C03;&#x9884;&#x7559;&#x63A5;&#x53E3;</span>
   launcher.initBeforeAtlas(mRawApplication.getBaseContext());

   <span class="hljs-comment">//2.3 &#x521D;&#x59CB;&#x5316;atlas     </span>
   Atlas.getInstance().init(mRawApplication, mIsUpdated);

   <span class="hljs-comment">//2.4 &#x5904;&#x7406;provider    </span>
    AtlasHacks.ActivityThread$AppBindData_providers.set(mBoundApplication,<span class="hljs-keyword">null</span>);
}
</code></pre>
<p>&#x51FD;&#x6570;&#x5B9E;&#x73B0;&#x5927;&#x6982;&#x5206;&#x4E3A;&#x56DB;&#x4E2A;&#x90E8;&#x5206;&#xFF0C;&#x4E5F;&#x662F;&#x672C;&#x7BC7;&#x6587;&#x7AE0;&#x7684;&#x91CD;&#x70B9;&#x5173;&#x6CE8;&#x90E8;&#x5206;</p>
<ul>
<li>hook&#x4E4B;&#x524D;&#x7684;&#x51C6;&#x5907;&#x5DE5;&#x4F5C;</li>
<li>&#x56DE;&#x8C03;&#x9884;&#x7559;&#x63A5;&#x53E3;</li>
<li>&#x521D;&#x59CB;&#x5316;atlas</li>
<li>&#x5904;&#x7406;provider</li>
</ul>
<p>&#x6211;&#x4EEC;&#x4E5F;&#x4E00;&#x4E2A;&#x6765;&#x770B;&#x3002;</p>
<h1 id="3-atlashacksdefineandverify">3. AtlasHacks.defineAndVerify</h1>
<p>&#x5728;&#x5F00;&#x59CB;&#x5206;&#x6790;&#x4E4B;&#x524D;&#xFF0C;&#x6211;&#x4EEC;&#x8981;&#x77E5;&#x9053;&#xFF0C;Android&#x4E0A;&#x52A8;&#x6001;&#x52A0;&#x8F7D;&#x65B9;&#x6848;&#xFF0C;&#x59CB;&#x7EC8;&#x90FD;&#x7ED5;&#x4E0D;&#x8FC7;&#x4E09;&#x4E2A;&#x5173;&#x952E;&#x7684;&#x70B9;:</p>
<ul>
<li><strong>&#x52A8;&#x6001;&#x52A0;&#x8F7D;class</strong> </li>
<li><strong>&#x52A8;&#x6001;&#x52A0;&#x8F7D;&#x8D44;&#x6E90;</strong> </li>
<li><strong>&#x5904;&#x7406;&#x56DB;&#x5927;&#x7EC4;&#x4EF6;</strong> &#x80FD;&#x591F;&#x8BA9;&#x52A8;&#x6001;&#x4EE3;&#x7801;&#x4E2D;&#x7684;&#x56DB;&#x5927;&#x7EC4;&#x4EF6;&#x5728;Android&#x4E0A;&#x6B63;&#x5E38;&#x8DD1;&#x8D77;&#x6765;</li>
</ul>
<p>&#x4E3A;&#x4E86;&#x5B9E;&#x73B0;&#x8FD9;&#x4E09;&#x4E2A;&#x76EE;&#x6807;&#xFF0C;&#x4F1A;&#x5728;&#x7CFB;&#x7EDF;&#x5173;&#x952E;&#x8C03;&#x7528;&#x7684;&#x5730;&#x65B9;&#x8FDB;&#x884C;Hook&#x3002;&#x6BD4;&#x5982;&#xFF0C;&#x4E3A;&#x4E86;&#x80FD;&#x591F;&#x52A8;&#x6001;&#x52A0;&#x8F7D;class&#xFF0C;&#x901A;&#x5E38;&#x90FD;&#x4F1A;&#x5BF9;classloader&#x4E0A;&#x52A8;&#x4E00;&#x4E9B;&#x624B;&#x811A;&#xFF0C;resource&#x4E5F;&#x662F;&#x7C7B;&#x4F3C;&#x3002;</p>
<p>&#x8FD9;&#x91CC;&#x591A;&#x63D0;&#x4E00;&#x53E5;&#xFF0C;&#x5728;&#x56DB;&#x5927;&#x7EC4;&#x4EF6;&#x7684;&#x5904;&#x7406;&#x4E0A;&#xFF0C;atals&#x4E0E;&#x63D2;&#x4EF6;&#x5316;&#x6709;&#x7740;&#x5F88;&#x5927;&#x7684;&#x5DEE;&#x5F02;&#x3002;</p>
<ul>
<li>&#x63D2;&#x4EF6;&#x5316;&#x7684;&#x6838;&#x5FC3;&#x601D;&#x60F3;&#x5176;&#x5B9E;&#x662F;&#x57CB;&#x5751;&#x673A;&#x5236;+&#x501F;&#x5C38;&#x8FD8;&#x9B42; &#xFF1A;&#x901A;&#x8FC7;&#x9884;&#x5148;&#x5728;manifest&#x4E2D;&#x9884;&#x7559;N&#x4E2A;&#x7EC4;&#x4EF6;&#x5751;&#xFF0C;&#x5728;runtime&#x65F6;&#xFF0C;&#x901A;&#x8FC7;&#x201C;&#x501F;&#x5C38;&#x8FD8;&#x9B42;&#x201D;&#x5B9E;&#x73B0;&#x56DB;&#x5927;&#x7EC4;&#x4EF6;&#x7684;&#x8FD0;&#x884C;&#x3002;</li>
<li>atlas&#x4E0D;&#x4E00;&#x6837;&#xFF0C;&#x5B83;&#x662F;&#x5728;&#x7F16;&#x8BD1;&#x671F;&#x5C31;&#x5DF2;&#x7ECF;&#x5404;&#x4E2A;bundle&#x7684;manifest&#x5199;&#x5165;&#x5230;apk&#x4E2D;&#x3002;&#x6240;&#x4EE5;&#x8FD0;&#x884C;&#x65F6;&#xFF0C;bundle&#x4E2D;&#x7684;&#x7EC4;&#x4EF6;&#x53EF;&#x4EE5;&#x548C;&#x5E38;&#x89C4;&#x58F0;&#x660E;&#x7684;&#x7EC4;&#x4EF6;&#x4E00;&#x6837;&#x6B63;&#x5E38;&#x8FD0;&#x884C;&#xFF0C;&#x4E0D;&#x7528;&#x518D;&#x505A;&#x989D;&#x5916;&#x7684;&#x5904;&#x7406;&#x3002;</li>
</ul>
<p>&#x56DE;&#x8FC7;&#x5934;&#x6765;&#xFF0C;&#x6211;&#x4EEC;&#x770B;&#x770B;atlas&#x4E3A;&#x4E86;&#x5B9E;&#x73B0;&#x4E0A;&#x8FF0;&#x76EE;&#x7684;&#xFF0C;&#x505A;&#x4E86;&#x54EA;&#x4E9B;&#x51C6;&#x5907;&#x5DE5;&#x4F5C;&#x3002;&#x5728;&#x8DDF;&#x8FDB;<code>defineAndVerify</code>&#x51FD;&#x6570;&#x7684;&#x5B9E;&#x73B0;&#x4E4B;&#x524D;&#xFF0C;&#x5148;&#x770B;&#x4E00;&#x4E0B;AtlasHacks&#x7C7B;&#x4E2D;&#x5B9A;&#x4E49;&#x7684;&#x5B57;&#x6BB5;</p>
<pre><code>//AtlasHacks.java

     // Classes
    public static HackedClass&lt;Object&gt;                           LoadedApk;
    public static HackedClass&lt;Object&gt;                           ActivityThread;
    public static HackedClass&lt;android.content.res.Resources&gt;    Resources;

    // Fields
    public static HackedField&lt;Object, Instrumentation&gt;          ActivityThread_mInstrumentation;
    public static HackedField&lt;Object, Application&gt;              LoadedApk_mApplication;
    public static HackedField&lt;Object, Resources&gt;                LoadedApk_mResources;

    // Methods
    public static HackedMethod                                  ActivityThread_currentActivityThread;
    public static HackedMethod                                  AssetManager_addAssetPath;
    public static HackedMethod                                  Application_attach;
    public static HackedField&lt;Object, ClassLoader&gt;              LoadedApk_mClassLoader;

    // Constructor
    public static Hack.HackedConstructor                        PackageParser_constructor;
</code></pre><p>&#x7ED9;&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#x70B9;&#x4E2A;&#x8D5E;&#xFF0C;&#x975E;&#x5E38;&#x7684;&#x5E72;&#x51C0;&#x548C;&#x6E05;&#x6670;&#x3002;&#x4EE3;&#x7801;&#x5B9A;&#x4E49;&#x4E86;atlas&#x6846;&#x67B6;&#x6240;&#x9700;&#x8981;hook&#x7684;&#x6240;&#x6709;&#x7684;&#x7C7B;&#x3001;&#x65B9;&#x6CD5;&#x3001;&#x5C5E;&#x6027;&#x7B49;&#x7B49;&#x5B57;&#x6BB5;&#x3002;</p>
<ul>
<li>&#x5904;&#x7406;&#x8D44;&#x6E90;&#xFF0C;hook Resources</li>
<li>&#x5904;&#x7406;class&#xFF0C;hook LoadedApk_mClassLoader</li>
<li>...</li>
</ul>
<p>&#x73B0;&#x5728;&#xFF0C;&#x5728;&#x770B;<code>defineAndVerify</code>&#x51FD;&#x6570;&#x7684;&#x5B9E;&#x73B0;</p>
<pre><code>//AtlasHacks.java
public static boolean defineAndVerify() throws AssertionArrayException {
     allClasses();
     allConstructors();
     allFields();
     allMethods();
}
</code></pre><p>&#x5B9E;&#x9645;&#x4E0A;&#x8FD9;&#x56DB;&#x4E2A;&#x7EA7;&#x522B;&#x7684;&#x51FD;&#x6570;&#x8C03;&#x7528;&#xFF0C;&#x5BF9;&#x5E94;&#x4E4B;&#x524D;&#x5B9A;&#x4E49;&#x7684;&#x5B57;&#x6BB5;&#xFF0C;&#x4E3A;&#x8FD9;&#x4E9B;&#x5B57;&#x6BB5;&#x8FDB;&#x884C;&#x8D4B;&#x503C;&#x3002;</p>
<pre><code class="lang-java"><span class="hljs-comment">//AtlasHacks.java</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">allClasses</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> HackAssertionException </span>{
    LoadedApk = Hack.into(<span class="hljs-string">&quot;android.app.LoadedApk&quot;</span>);
    ActivityThread = Hack.into(<span class="hljs-string">&quot;android.app.ActivityThread&quot;</span>);
    Resources = Hack.into(Resources.class);
    ActivityManager = Hack.into(<span class="hljs-string">&quot;android.app.ActivityManager&quot;</span>);
    <span class="hljs-comment">//...</span>
}

<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">allFields</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> HackAssertionException </span>{
    ActivityThread_mInstrumentation = ActivityThread.field(<span class="hljs-string">&quot;mInstrumentation&quot;</span>).ofType(Instrumentation.class);
    ActivityThread_mAllApplications = ActivityThread.field(<span class="hljs-string">&quot;mAllApplications&quot;</span>).ofGenericType(ArrayList.class);
}

<span class="hljs-comment">//...</span>
</code></pre>
<p>&#x8FD9;&#x51E0;&#x4E2A;&#x51FD;&#x6570;&#x7684;&#x4EE3;&#x7801;&#x5E76;&#x4E0D;&#x590D;&#x6742;&#xFF0C;&#x662F;&#x5BF9;&#x5B9A;&#x4E49;&#x7684;Class&#x3001;Field&#x3001;Method&#x548C;Contructor &#x8FD9;&#x4E9B;&#x5B57;&#x6BB5;&#x8FDB;&#x884C;&#x521D;&#x59CB;&#x5316;&#x8D4B;&#x503C;&#x5DE5;&#x4F5C;&#x3002;</p>
<p>&#x6267;&#x884C;&#x5230;&#x8FD9;&#x91CC;&#x65F6;&#xFF0C;atlas&#x6846;&#x67B6;&#x7684;&#x51C6;&#x5907;&#x5DE5;&#x4F5C;&#x5B8C;&#x6210;&#xFF0C;&#x63A5;&#x4E0B;&#x6765;&#xFF0C;&#x5C31;&#x662F;&#x6574;&#x4E2A;&#x6846;&#x67B6;&#x7684;&#x521D;&#x59CB;&#x5316;&#x4E86;&#x3002;</p>
<h1 id="4-&#x56DE;&#x8C03;&#x9884;&#x7559;&#x63A5;&#x53E3;">4 &#x56DE;&#x8C03;&#x9884;&#x7559;&#x63A5;&#x53E3;</h1>
<p>&#x65F6;&#x5E8F;&#x56FE;&#x4E2D;&#x7684;&#x7B2C;4&#x6B65;&#xFF0C;&#x5373;<code>BridgeApplicationDelegate</code>&#x7684;<code>attachBaseContext</code>&#x65B9;&#x6CD5;&#x4E2D;&#xFF0C;&#xFF0C;&#x505A;&#x4E86;&#x4E00;&#x4E2A;&#x63A5;&#x53E3;&#x56DE;&#x8C03;&#x3002;</p>
<p>BridgeApplicationDelegate.java</p>
<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">attachBaseContext</span><span class="hljs-params">()</span></span>{
   String preLaunchStr = (String) RuntimeVariables.getFrameworkProperty(<span class="hljs-string">&quot;preLaunch&quot;</span>);
   AtlasPreLauncher launcher = (AtlasPreLauncher) Class.forName(preLaunchStr).newInstance();
   launcher.initBeforeAtlas(mRawApplication.getBaseContext());
   <span class="hljs-comment">//...</span>
}
</code></pre>
<p>&#x51FD;&#x6570;&#x901A;&#x8FC7;&#x201C;preLaunch&#x201D;&#x5B57;&#x6BB5;&#x8BFB;&#x53D6;&#x4E00;&#x4E2A;&#x7C7B;&#x540D;&#xFF0C;&#x53CD;&#x5C04;&#x8BE5;&#x7C7B;&#x4E0A;&#x7684;<code>initBeforeAtlas</code>&#x65B9;&#x6CD5;&#x3002;<br>
<code>AtlasPreLauncher</code>&#x5B9E;&#x9645;&#x4E0A;&#x662F;&#x4E00;&#x4E2A;&#x63A5;&#x53E3;&#xFF0C;&#x4F9B;&#x63A5;&#x5165;&#x8005;&#x4F7F;&#x7528;&#x3002;&#x5728;&#x8FD9;&#x4E2A;&#x70B9;&#xFF0C;atlas&#x8FD8;&#x6CA1;&#x6709;&#x5F00;&#x59CB;&#x5BF9;&#x7CFB;&#x7EDF;&#x8FDB;&#x884C;hook&#xFF0C;&#x4ECD;&#x7136;&#x662F;Android&#x539F;&#x751F;&#x6001;&#x7684;&#x8FD0;&#x884C;&#x65F6;&#x73AF;&#x5883;&#x3002;</p>
<p>&#x90A3;&#x4E48;&#x8FD9;&#x4E2A;preLaunch&#x7684;&#x5B57;&#x6BB5;&#x5728;&#x54EA;&#x91CC;&#x5B9A;&#x4E49;&#x7684;&#x5462;&#xFF0C;&#x6211;&#x4EEC;&#x53CD;&#x63A8;&#x4E00;&#x4E0B;&#x3002;</p>
<p>RuntimeVariables.java</p>
<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> Object <span class="hljs-title">getFrameworkProperty</span><span class="hljs-params">(String fieldName)</span></span>{
    <span class="hljs-comment">//...</span>
    Field field = FrameworkPropertiesClazz.getDeclaredField(fieldName);
    <span class="hljs-keyword">return</span> field.get(FrameworkPropertiesClazz);
}
</code></pre>
<p>&#x5B9E;&#x73B0;&#x5F88;&#x7B80;&#x5355;&#xFF0C;&#x8BFB;&#x53D6;<code>FrameworkProperties</code>&#x4E0A;&#x7684;&#x9759;&#x6001;&#x5C5E;&#x6027;&#x5B57;&#x6BB5;&#xFF0C;&#x63A5;&#x7740;&#x8DDF;&#x8FDB;&#x3002;</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">FrameworkProperties</span> </span>{
}
</code></pre>
<p>&#x4EC0;&#x4E48;&#x60C5;&#x51B5;&#xFF0C;&#x600E;&#x4E48;&#x4EC0;&#x4E48;&#x90FD;&#x6CA1;&#x6709;? &#x6240;&#x8C13;&#x53CD;&#x5E38;&#x5373;&#x4E3A;&#x1F48A;&#xFF0C;&#x76F4;&#x63A5;&#x770B;&#x53CD;&#x7F16;&#x8BD1;&#x540E;&#x7684;&#x4EE3;&#x7801;</p>
<p>FrameworkProperties.java</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">FrameworkProperties</span></span>{
  <span class="hljs-comment">//...</span>
  <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> String autoStartBundles;
  <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> String preLaunch;

  <span class="hljs-keyword">static</span>{
    autoStartBundles = <span class="hljs-string">&quot;com.taobao.firstbundle&quot;</span>;
    preLaunch = <span class="hljs-string">&quot;com.taobao.demo.DemoPreLaunch&quot;</span>;
  }
}
</code></pre>
<p>&#x4ECE;&#x53CD;&#x7F16;&#x8BD1;&#x540E;&#x7684;&#x4EE3;&#x7801;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&quot;prelaunch&quot;&#x5BF9;&#x5E94;&#x7684;&#x5185;&#x5BB9;&#x662F;<code>com.taobao.demo.DemoPreLaunch</code>,&#x90A3;&#x4E48;&#x8FD9;&#x4E2A;&#x503C;&#x662F;&#x5728; <strong>&#x4EC0;&#x4E48;&#x65F6;&#x5019;&#x5199;&#x5165;&#x53C8;&#x662F;&#x5728;&#x54EA;&#x91CC;&#x914D;&#x7F6E;</strong> &#x7684;&#x5462;&#xFF1F;</p>
<p>&#x5927;&#x5BB6;&#x56DE;&#x60F3;&#x4E00;&#x4E0B;&#xFF0C;&#x5728;&#x4E4B;&#x524D;<a href="../atlas_gradle_apk/atlas_atlas_gradle_apk.html">Atlas&#x4E4B;Gradle&#x914D;&#x7F6E;</a>&#x4E2D;&#x63D0;&#x5230;&#x8FC7;&#xFF0C;atlas&#x7684;gradle&#x63D2;&#x4EF6;&#x5728;&#x7F16;&#x8BD1;&#x671F;&#x641E;&#x4E86;&#x5F88;&#x591A;&#x4E8B;&#x60C5;&#xFF0C;&#x6211;&#x4EEC;&#x770B;gradle&#x4E2D;&#x7684;&#x8BBE;&#x7F6E;</p>
<pre><code class="lang-gradle">atlas{
     tBuildConfig {
        autoStartBundles = [<span class="hljs-string">&apos;com.taobao.firstbundle&apos;</span>]
        preLaunch = <span class="hljs-string">&apos;com.taobao.demo.DemoPreLaunch&apos;</span>
    }
}
</code></pre>
<p>&#x548C;<code>FrameworkProperties</code>&#x4E2D;&#x7684;&#x5B57;&#x6BB5;&#x5B8C;&#x7F8E;&#x5BF9;&#x5E94;&#x3002;</p>
<p>&#x8FD9;&#x4E2A;&#x90E8;&#x5206;&#x7275;&#x6D89;&#x5F00;&#x53D1;-&#x7F16;&#x8BD1;-&#x8FD0;&#x884C;&#x4E09;&#x4E2A;&#x9636;&#x6BB5;&#xFF0C;&#x653E;&#x4E00;&#x5F20;&#x56FE;&#x634B;&#x4E00;&#x4E0B;&#x5173;&#x7CFB;&#x3002;</p>
<p><img src="atlas_framework_property.svg" alt=""></p>
<h1 id="5-atlasinit">5 atlas.init</h1>
<p>&#x51C6;&#x5907;&#x5DE5;&#x4F5C;&#x505A;&#x597D;&#x4E4B;&#x540E;&#xFF0C;&#x5C31;&#x662F;&#x521D;&#x59CB;&#x5316;&#x4E86;&#x3002;</p>
<p>Atlas.java</p>
<pre><code>public void init(Application application,boolean reset) {
    //&#x8BFB;&#x53D6;&#x914D;&#x7F6E;&#x9879;
    ApplicationInfo appInfo = mRawApplication.get...;
    mRealApplicationName = appInfo.metaData.getString(&quot;REAL_APPLICATION&quot;);
    boolean multidexEnable = appInfo.metaData.getBoolean(&quot;multidex_enable&quot;);

    if(multidexEnable){
      MultiDex.install(mRawApplication);
   }
    //...   
}
</code></pre><p>&#x9996;&#x5148;&#x662F;&#x8BFB;&#x53D6;manifest&#x4E2D;&#x7684;&#x914D;&#x7F6E;&#x6570;&#x636E;<code>multidexEnable</code>&#x548C;<code>mRealApplicationName</code>&#xFF0C;&#x8FD9;&#x4E24;&#x4E2A;&#x6570;&#x636E;&#x4E5F;&#x662F;&#x5728;&#x7F16;&#x8BD1;&#x671F;&#x7531;atlas&#x63D2;&#x4EF6;&#x5199;&#x5230;manifest&#x4E2D;&#x7684;&#x3002;</p>
<p><img src="atlas_meta_data.png" alt=""></p>
<p>multidexEnable &#x662F;true&#xFF0C;&#x8FD9;&#x4E2A;&#x5728;gradle&#x4E2D;&#x53EF;&#x914D;<br>
mRealApplicationName &#x5B9E;&#x9645;&#x4E0A;&#x662F;DemoApplication,&#x5373;app&#x5DE5;&#x7A0B;&#x5728;manifest&#x4E2D;&#x6307;&#x5B9A;&#x7684;&#x542F;&#x52A8;&#x8DEF;&#x5F84;&#x3002;</p>
<p>&#x634B;&#x6E05;&#x695A;&#x8FD9;&#x51E0;&#x4E2A;&#x53C2;&#x6570;&#x4E4B;&#x540E;&#xFF0C;&#x5F80;&#x4E0B;&#x770B;Atlas&#x6846;&#x67B6;&#x521D;&#x59CB;&#x5316;&#x5B9E;&#x73B0;</p>
<p>Atlas.java</p>
<pre><code>public void init(Application application,boolean reset) {
   //...
   Atlas.getInstance().init(mRawApplication, mIsUpdated);
}

public void init(Application application,boolean reset) throws AssertionArrayException, Exception {
     //...

     //1. &#x6362;classloader 
     AndroidHack.injectClassLoader(packageName, newClassLoader);
     //2. &#x6362;Instrumentatio
     AndroidHack.injectInstrumentationHook(new InstrumentationHook(AndroidHack.getInstrumentation(), application.getBaseContext()));
     //3. hook ams
     try {
         ActivityManagerDelegate activityManagerProxy = new ActivityManagerDelegate();
         Object gDefault = null;
         if(Build.VERSION.SDK_INT&gt;25 || (Build.VERSION.SDK_INT==25&amp;&amp;Build.VERSION.PREVIEW_SDK_INT&gt;0)){
             gDefault=AtlasHacks.ActivityManager_IActivityManagerSingleton.get(AtlasHacks.ActivityManager.getmClass());
         }else{
               gDefault=AtlasHacks.ActivityManagerNative_gDefault.get(AtlasHacks.ActivityManagerNative.getmClass());
         }
         AtlasHacks.Singleton_mInstance.hijack(gDefault, activityManagerProxy);
      }catch(Throwable e){}
      //4. hook H
      AndroidHack.hackH();
}
</code></pre><p>&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#xFF0C;&#x5C31;&#x662F;&#x5BF9;&#x7CFB;&#x7EDF;&#x5173;&#x952E;&#x8282;&#x70B9;&#x8FDB;&#x884C;&#x4E86;hook&#xFF0C;&#x5177;&#x4F53;&#x7684;hook&#x5B9E;&#x73B0;&#x8FD9;&#x91CC;&#x5C31;&#x4E0D;&#x8D34;&#x51FA;&#x4E86;&#xFF0C;&#x5982;&#x679C;&#x611F;&#x5174;&#x8DA3;&#xFF0C;&#x53EF;&#x4EE5;&#x53C2;&#x8003;<a href="https://github.com/alibaba/atlas" target="_blank">demo&#x6E90;&#x7801;</a>&#x4EE5;&#x53CA;<a href="http://weishu.me/" target="_blank">&#x7530;&#x7EF4;&#x672F;&#x7684;blog</a>&#xFF0C;&#x5982;&#x4F55;hook&#xFF0C;&#x4EE5;&#x53CA;&#x4E3A;&#x4EC0;&#x4E48;&#x5728;&#x8FD9;&#x91CC;hook&#xFF0C;&#x5728;&#x6587;&#x7AE0;&#x4E2D;&#x90FD;&#x8BB2;&#x7684;&#x975E;&#x5E38;&#x6E05;&#x695A;&#x3002;</p>
<p>&#x51FD;&#x6570;&#x4E2D;&#x7684;hook&#x70B9;</p>
<table>
<thead>
<tr>
<th>hook&#x70B9;</th>
<th>&#x5B9E;&#x4F8B;</th>
</tr>
</thead>
<tbody>
<tr>
<td>ActivityThread.mLoadedApk.mClassLoader</td>
<td>DelegateClassLoader</td>
</tr>
<tr>
<td>ActivityThread.mInstrumentation</td>
<td>InstrumentationHook</td>
</tr>
<tr>
<td>ActivityManagerNative.gDefault.get</td>
<td>ActivityManagerDelegate</td>
</tr>
<tr>
<td>android.app.ActivityThread$H.mCallback</td>
<td>ActivityThreadHook</td>
</tr>
</tbody>
</table>
<h1 id="6-&#x5904;&#x7406;provider">6. &#x5904;&#x7406;provider</h1>
<p>&#x5728;&#x7B2C;2&#x6B65;&#x7684;2.4&#x90E8;&#x5206;&#xFF0C;&#x5BF9;provider&#x8FDB;&#x884C;&#x4E86;&#x5904;&#x7406;</p>
<p>BridgeApplicationDelegate.java</p>
<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">attachBaseContext</span><span class="hljs-params">()</span></span>{
    <span class="hljs-comment">//...</span>

   <span class="hljs-comment">//2.4 &#x5904;&#x7406;provider</span>
   Object mBoundApplication = AtlasHacks.ActivityThread_mBoundApplication.get(activityThread);
   mBoundApplication_provider = AtlasHacks.ActivityThread$AppBindData_providers.get(mBoundApplication);
   <span class="hljs-keyword">if</span>(mBoundApplication_provider!=<span class="hljs-keyword">null</span> &amp;&amp; mBoundApplication_provider.size()&gt;<span class="hljs-number">0</span>){
           AtlasHacks.ActivityThread$AppBindData_providers.set(mBoundApplication,<span class="hljs-keyword">null</span>);
    }
}
</code></pre>
<p>&#x7B2C;4&#x884C;&#x4EE3;&#x7801;&#x8BFB;&#x53D6;provider&#x6570;&#x636E;&#xFF0C;&#x5982;&#x679C;&#x6709;provider&#x4FE1;&#x606F;&#x7684;&#x8BDD;&#xFF0C;&#x5219;&#x5728;&#x7B2C;6&#x884C;&#x4ECE;&#x7CFB;&#x7EDF;&#x5220;&#x9664;&#xFF0C;&#x8BA9;&#x7CFB;&#x7EDF;&#x8BA4;&#x4E3A;apk&#x5E76;&#x6CA1;&#x6709;&#x7533;&#x8BF7;&#x4EFB;&#x4F55;provider&#x3002;</p>
<p>&#x4E3A;&#x4EC0;&#x4E48;&#x8FD9;&#x4E48;&#x505A;?&#x56DE;&#x987E;&#x4E00;&#x4E0B;app&#x542F;&#x52A8;&#x7684;&#x6D41;&#x7A0B;</p>
<p><img src="atlas_core_start_provider_img.svg" alt=""></p>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x5728;&#x7B2C;4&#x6B65;&#x548C;&#x7B2C;7&#x6B65;&#x4E24;&#x4E2A;&#x5173;&#x952E;&#x8C03;&#x7528;&#x4E4B;&#x95F4;&#xFF0C;&#x7B2C;5&#x6B65;&#x8C03;&#x7528;&#x4E86;&#x51FD;&#x6570;<code>installContentProviders</code>,&#x8DDF;&#x8FDB;&#x53BB;&#x770B;&#x4E00;&#x4E0B;&#x3002;</p>
<pre><code>private void installContentProviders(Context context, List&lt;ProviderInfo&gt; providers) {
    for (ProviderInfo cpi : providers) {
        installProvider(context, null, cpi,...);
    }
}
</code></pre><p>&#x6536;&#x96C6;&#x4E86;&#x6240;&#x6709;provider&#x7684;&#x4FE1;&#x606F;&#xFF0C;&#x7136;&#x540E;&#x8C03;&#x7528;installProvider&#x51FD;&#x6570;</p>
<pre><code>private IActivityManager.ContentProviderHolder installProvider(Context context,IActivityManager.ContentProviderHolder holder, ProviderInfo info,...) {
    final java.lang.ClassLoader cl = c.getClassLoader();
   localProvider = (ContentProvider)cl.loadClass(info.name).newInstance();
   //...
}
</code></pre><p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x51FD;&#x6570;&#x662F;&#x6839;&#x636E;&#x5728;manifest&#x4E2D;&#x767B;&#x8BB0;&#x7684;provider&#x4FE1;&#x606F;&#xFF0C;&#x5B9E;&#x4F8B;&#x5316;&#x5BF9;&#x8C61;&#x3002;<br>
<strong>&#x90A3;&#x4E48;&#x95EE;&#x9898;&#x6765;&#x4E86;</strong>&#xFF0C;&#x6709;&#x4E9B;provider&#x662F;&#x5B58;&#x5728;&#x4E8E;bundle&#x4E2D;&#x7684;&#xFF0C;&#x4E3B;dex&#x4E2D;&#x5E76;&#x4E0D;&#x5B58;&#x5728;&#x3002;&#x5982;&#x679C;&#x4E0D;&#x5904;&#x7406;&#xFF0C;&#x5728;&#x8FD9;&#x91CC;&#x7A0B;&#x5E8F;&#x4F1A;&#x56E0;&#x4E3A;<code>ClassNotFind</code>&#x5D29;&#x6E83;&#x3002;&#x6240;&#x4EE5;&#x8FD9;&#x91CC;&#x8981;&#x5148;&#x6E05;&#x9664;&#x6389;provier&#x7684;&#x4FE1;&#x606F;&#xFF0C;&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x3002;</p>
<hr>
<p>&#x4E0A;&#x7BC7;&#x5148;&#x5230;&#x8FD9;&#x91CC;&#xFF0C;&#x5404;&#x4F4D;&#x5148;&#x559D;&#x53E3;&#x6C34;&#xFF0C;&#x518D;&#x6765;&#x4E0B;&#x7BC7;&#x7684;&#x5206;&#x6790;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../atlas_gradle_apk/atlas_atlas_gradle_apk.html" class="navigation navigation-prev " aria-label="Previous page: Atlas之Gradle配置">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="atlas_start_2.html" class="navigation navigation-next " aria-label="Next page: Atlas之启动过程(二)">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Atlas之启动过程(一)","date":"2017-05-02T15:00:00.000Z","level":"1.6.2","depth":2,"next":{"title":"Atlas之启动过程(二)","level":"1.6.3","depth":2,"path":"code_read/atlas_start/atlas_start_2.md","ref":"code_read/atlas_start/atlas_start_2.md","articles":[]},"previous":{"title":"Atlas之Gradle配置","level":"1.6.1","depth":2,"path":"code_read/atlas_gradle_apk/atlas_atlas_gradle_apk.md","ref":"code_read/atlas_gradle_apk/atlas_atlas_gradle_apk.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"code_read/atlas_start/atlas_start_1.md","mtime":"2017-09-12T02:32:41.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-11-27T10:00:49.012Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

